package com.study.design;

/**
 * 双检锁/双重校验锁（DCL，即 double-checked locking）
 * @author Administrator
 */
public class DoubleCheckedSingleton {
    private static volatile DoubleCheckedSingleton instance;

    private DoubleCheckedSingleton() {
    }

    public static DoubleCheckedSingleton getInstance() {
        if (instance == null) {
            synchronized (DoubleCheckedSingleton.class) {
                if (instance == null) {
                    instance = new DoubleCheckedSingleton();
                }
            }
        }
        return instance;
    }


    public String test() {
        return "测试成功";
    }


}
